<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>js</title>
</head>
<body>
	<h1 info='linux is very much!' id='hid' class='hcls'>kkkkkkkkkkkkkk</h1>
</body>
<script>
	
	//将getAttribute和setAttribute封装为函数
	hidobj=document.getElementById('hid');

	function getA(obj,attr){
		return obj.getAttribute(attr);
	}

	alert(getA(hidobj,'info')); //获取info 的属性
	alert(getA(hidobj,'class')); //获取class 的属性

	//将setAttribute封装为函数
	function setA(obj,attr,value){
		if(obj.setAttribute(attr,value)){
			return true;
		}else{
			return false;
		}
	}
	setA(hidobj,'info','php is very much');
</script>
</html>